package org.gap.service;

import java.util.List;
import java.util.Set;

import org.gap.domain.Patient;
import org.gap.domain.RendezVous;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/GAP_v2-security-context.xml",
		"file:./resources/GAP_v2-service-context.xml",
		"file:./resources/GAP_v2-dao-context.xml",
		"file:./resources/GAP_v2-web-context.xml" })
@Transactional
public class RendezVousServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected RendezVousService service;

	/**
	 * Instantiates a new RendezVousServiceTest.
	 *
	 */
	public RendezVousServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 * Load an existing RendezVous entity
	 * 
	 */
	@Test
	public void loadRendezVouss() {
		Set<RendezVous> response = null;
		response = service.loadRendezVouss();
		// TODO: JUnit - Add assertions to test outputs of operation: loadRendezVouss
	}

	/**
	 * Operation Unit Test
	 * Save an existing RendezVous entity
	 * 
	 */
	@Test
	public void saveRendezVous() {
		// TODO: JUnit - Populate test inputs for operation: saveRendezVous 
		RendezVous rendezvous = new org.gap.domain.RendezVous();
		service.saveRendezVous(rendezvous);
	}

	/**
	 * Operation Unit Test
	 * Return all RendezVous entity
	 * 
	 */
	@Test
	public void findAllRendezVouss() {
		// TODO: JUnit - Populate test inputs for operation: findAllRendezVouss 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<RendezVous> response = null;
		response = service.findAllRendezVouss(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllRendezVouss
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Patient entity
	 * 
	 */
	@Test
	public void deleteRendezVousPatient() {
		// TODO: JUnit - Populate test inputs for operation: deleteRendezVousPatient 
		Integer rendezvous_rdvRendezVous = 0;
		Integer related_patient_patPatient = 0;
		RendezVous response = null;
		response = service.deleteRendezVousPatient(rendezvous_rdvRendezVous, related_patient_patPatient);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteRendezVousPatient
	}

	/**
	 * Operation Unit Test
	 * Delete an existing RendezVous entity
	 * 
	 */
	@Test
	public void deleteRendezVous() {
		// TODO: JUnit - Populate test inputs for operation: deleteRendezVous 
		RendezVous rendezvous_1 = new org.gap.domain.RendezVous();
		service.deleteRendezVous(rendezvous_1);
	}

	/**
	 * Operation Unit Test
	 * Save an existing Patient entity
	 * 
	 */
	@Test
	public void saveRendezVousPatient() {
		// TODO: JUnit - Populate test inputs for operation: saveRendezVousPatient 
		Integer rdvRendezVous = 0;
		Patient related_patient = new org.gap.domain.Patient();
		RendezVous response = null;
		response = service.saveRendezVousPatient(rdvRendezVous, related_patient);
		// TODO: JUnit - Add assertions to test outputs of operation: saveRendezVousPatient
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findRendezVousByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findRendezVousByPrimaryKey 
		Integer rdvRendezVous_1 = 0;
		RendezVous response = null;
		response = service.findRendezVousByPrimaryKey(rdvRendezVous_1);
		// TODO: JUnit - Add assertions to test outputs of operation: findRendezVousByPrimaryKey
	}

	/**
	 * Operation Unit Test
	 * Return a count of all RendezVous entity
	 * 
	 */
	@Test
	public void countRendezVouss() {
		Integer response = null;
		response = service.countRendezVouss();
		// TODO: JUnit - Add assertions to test outputs of operation: countRendezVouss
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
